import { Instance, SnapshotIn, SnapshotOut, types } from "mobx-state-tree"

import { withSetPropAction } from "./helpers/withSetPropAction"

/**
 * Model description here for TypeScript hints.
 */
export const OrderModel = types
  .model("Order")
  .props({
    orderNum: types.optional(types.array(types.string), []),
  })
  .actions(withSetPropAction)
  .views((self) => ({})) // eslint-disable-line @typescript-eslint/no-unused-vars
  .actions((self) => ({})) // eslint-disable-line @typescript-eslint/no-unused-vars

export interface Order extends Instance<typeof OrderModel> {}

export interface OrderSnapshotOut extends SnapshotOut<typeof OrderModel> {}

export interface OrderSnapshotIn extends SnapshotIn<typeof OrderModel> {}

export const createOrderDefaultModel = () => types.optional(OrderModel, {})

export interface MemberDetail {
  level: string
  rewardCoinImmediate: number
  rewardCoinDaily: number
  checkInRewardDaily: number
  days: number
  describe: string
  welfares: any
  benefits: any
}

// 产品信息类型
export interface Product {
  id: number
  type: string // member, coin
  subId: string
  name: string
  price: number
  desc: string | any
  expireDays: number
  appleSku: string
  appleSubscribeSku: string
  localizedPrice?: string
  localizedPriceUnit?: string
  coin: number
  times: number
  showType: string // coin, times
  tips: string
  selectionImage: string
  selectionImageActive: string
  currentImage: string
  right1ImgUrl: string
  right2ImgUrl: string
  memberDetail: MemberDetail
  disabled?: boolean
  tag?: string
  once?: boolean
}

// 获取产品列表响应
export interface GetProductsData {
  products: Product[]
}

export interface GetProductsResp {
  data: GetProductsData
}

// 创建订单请求与响应
export interface CreateOrderReq {
  productId: number
}

// 创建订单请求与响应
export interface GetOrderReq {
  orderNum: number
}

export interface CreateOrderData {
  orderNum: string
}

export interface CreateOrderResp {
  data: CreateOrderData
}

// 创建微信支付请求与响应
export interface CreateWxPaymentReq {
  orderId: number
}

export interface CreateWxPaymentData {
  paymentId: number
  appId: string
  timeStamp: string
  nonce: string
  sign: string
  package: string
}

export interface CreateWxPaymentResp {
  data: CreateWxPaymentData
}

// 创建支付宝支付请求与响应
export interface CreateAliPaymentReq {
  orderNum: string
}

export interface CreateAliPaymentData {
  orderStr: string
}

export interface CreateAliPaymentResp {
  data: CreateAliPaymentData
}

// App Store 交易验证请求
export interface VerifyIAPAppStoreTransactionReq {
  transactionId?: any
  orderNum?: string
}

// App Store 交易验证请求
export interface VerifyIAPGooglePlayPurchaseReq {
  packageNameAndroid?: string
  productId?: string
  purchaseToken?: string
}
